import http from '../utils/request'

// 用户相关接口
export const userApi = {
  // 手机号登录
  loginByPhone: (data) => http.post('user/login/phone', data),
  
  // 微信登录
  loginByWechat: (data) => http.post('user/wx_login', data),
  
  // 发送验证码
  sendCode: (phone) => http.post('user/send-code', { phone }),
  
  // 获取用户信息
  getUserInfo: () => http.get('user/info'),
  
  // 更新用户信息
  updateUserInfo: (data) => http.put('user/info', data)
}

// 医生相关接口
export const doctorApi = {
  // 获取医生列表
  getDoctorList: (params) => http.get('doctor/list', params),
  
  // 获取医生详情
  getDoctorDetail: (id) => http.get(`doctor/${id}`),
  
  // 获取医生评价
  getDoctorReviews: (id, params) => http.get(`doctor/${id}/reviews`, params)
}

// 问诊相关接口
export const consultationApi = {
  // 创建问诊
  createConsultation: (data) => http.post('consultation/create', data),
  
  // 获取问诊列表
  getConsultationList: (params) => http.get('consultation/list', params),
  
  // 获取问诊详情
  getConsultationDetail: (id) => http.get(`consultation/${id}`),
  
  // 发送消息
  sendMessage: (id, data) => http.post(`consultation/${id}/message`, data)
}

// 预约相关接口
export const appointmentApi = {
  // 获取可预约时间
  getAvailableTime: (params) => http.get('appointment/available-time', params),
  
  // 创建预约
  createAppointment: (data) => http.post('appointment/create', data),
  
  // 获取预约列表
  getAppointmentList: (params) => http.get('appointment/list', params),
  
  // 取消预约
  cancelAppointment: (id) => http.put(`appointment/${id}/cancel`)
}

// 药品相关接口
export const pharmacyApi = {
  // 获取药品分类
  getCategories: () => http.get('pharmacy/categories'),
  
  // 获取药品列表
  getMedicineList: (params) => http.get('pharmacy/medicines', params),
  
  // 获取药品详情
  getMedicineDetail: (id) => http.get(`pharmacy/medicines/${id}`),
  
  // 创建订单
  createOrder: (data) => http.post('pharmacy/orders', data)
}

// 健康档案相关接口
export const healthRecordApi = {
  // 获取健康档案
  getHealthRecords: () => http.get('health/records'),
  
  // 更新健康档案
  updateHealthRecord: (data) => http.put('health/records', data),
  
  // 获取体检报告
  getCheckupReports: () => http.get('health/checkup-reports'),
  
  // 获取体检报告详情
  getCheckupReportDetail: (id) => http.get(`health/checkup-reports/${id}`)
}

// 社区相关接口
export const communityApi = {
  // 获取文章列表
  getArticles: (params) => http.get('community/articles', params),
  
  // 获取文章详情
  getArticleDetail: (id) => http.get(`community/articles/${id}`),
  
  // 获取评论列表
  getComments: (id, params) => http.get(`community/articles/${id}/comments`, params),
  
  // 发表评论
  postComment: (id, data) => http.post(`community/articles/${id}/comments`, data)
} 